/*
 Navicat Premium Data Transfer

 Source Server         : Local PG
 Source Server Type    : PostgreSQL
 Source Server Version : 170000 (170000)
 Source Host           : localhost:5432
 Source Catalog        : chat_server
 Source Schema         : public

 Target Server Type    : PostgreSQL
 Target Server Version : 170000 (170000)
 File Encoding         : 65001

 Date: 10/11/2024 09:19:12
*/


-- ----------------------------
-- Sequence structure for sys_channel_id_seq
-- ----------------------------
DROP SEQUENCE IF EXISTS "sys_channel_id_seq";
CREATE SEQUENCE "sys_channel_id_seq" 
INCREMENT 1
MINVALUE  1
MAXVALUE 10000000
START 1
CACHE 1
CYCLE ;

-- ----------------------------
-- Sequence structure for sys_user_code_seq
-- ----------------------------
DROP SEQUENCE IF EXISTS "sys_user_code_seq";
CREATE SEQUENCE "sys_user_code_seq" 
INCREMENT 1
MINVALUE  100000
MAXVALUE 999999
START 100000
CACHE 1
CYCLE ;

-- ----------------------------
-- Table structure for sys_channel
-- ----------------------------
DROP TABLE IF EXISTS "sys_channel";
CREATE TABLE "sys_channel" (
  "id" int4 NOT NULL GENERATED ALWAYS AS IDENTITY (
INCREMENT 1
MINVALUE  1
MAXVALUE 10000000
START 1
CACHE 1
CYCLE
),
  "name" varchar(255) COLLATE "pg_catalog"."default",
  "avatar" varchar(255) COLLATE "pg_catalog"."default",
  "type" int2,
  "parent_id" int4,
  "create_time" timestamp(6),
  "update_time" timestamp(6)
)
;
COMMENT ON COLUMN "sys_channel"."type" IS '频道类型';
COMMENT ON COLUMN "sys_channel"."parent_id" IS '父频道id';

-- ----------------------------
-- Records of sys_channel
-- ----------------------------
BEGIN;
INSERT INTO "sys_channel" ("id", "name", "avatar", "type", "parent_id", "create_time", "update_time") OVERRIDING SYSTEM VALUE VALUES (1, 'orange', NULL, NULL, NULL, NULL, NULL);
COMMIT;

-- ----------------------------
-- Table structure for sys_guild
-- ----------------------------
DROP TABLE IF EXISTS "sys_guild";
CREATE TABLE "sys_guild" (
  "id" uuid NOT NULL DEFAULT uuid_generate_v4(),
  "name" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
  "avatar" varchar(255) COLLATE "pg_catalog"."default",
  "status" int2 NOT NULL DEFAULT 1,
  "create_time" timestamp(6) NOT NULL,
  "update_time" timestamp(6) NOT NULL
)
;

-- ----------------------------
-- Records of sys_guild
-- ----------------------------
BEGIN;
INSERT INTO "sys_guild" ("id", "name", "avatar", "status", "create_time", "update_time") VALUES ('fe05e724-54f5-422d-8dd8-e6d1b4de542e', 'orange', '/img/orange', 1, '2024-11-07 17:26:10', '2024-11-07 17:26:12');
COMMIT;

-- ----------------------------
-- Table structure for sys_user
-- ----------------------------
DROP TABLE IF EXISTS "sys_user";
CREATE TABLE "sys_user" (
  "id" uuid NOT NULL DEFAULT uuid_generate_v4(),
  "create_time" timestamp(6) NOT NULL,
  "update_time" timestamp(6) NOT NULL,
  "password" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
  "code" int8 NOT NULL GENERATED ALWAYS AS IDENTITY (
INCREMENT 1
MINVALUE  100000
MAXVALUE 999999
START 100000
CACHE 1
CYCLE
),
  "email" varchar(255) COLLATE "pg_catalog"."default",
  "account" varchar(255) COLLATE "pg_catalog"."default",
  "status" int2 NOT NULL DEFAULT 1
)
;
COMMENT ON COLUMN "sys_user"."id" IS '用户id';
COMMENT ON COLUMN "sys_user"."create_time" IS '创建时间';
COMMENT ON COLUMN "sys_user"."update_time" IS '更新时间';
COMMENT ON COLUMN "sys_user"."password" IS '密码';
COMMENT ON COLUMN "sys_user"."code" IS '用户标识';
COMMENT ON COLUMN "sys_user"."email" IS '邮箱';
COMMENT ON COLUMN "sys_user"."account" IS '用户名(结合标识用作登录)';
COMMENT ON COLUMN "sys_user"."status" IS '状态';

-- ----------------------------
-- Records of sys_user
-- ----------------------------
BEGIN;
INSERT INTO "sys_user" ("id", "create_time", "update_time", "password", "code", "email", "account", "status") OVERRIDING SYSTEM VALUE VALUES ('73ac52cb-9538-43e8-ad36-ad251fc415a4', '2024-11-07 14:25:56', '2024-11-07 14:25:59', '$2b$12$WX/ISgd/T/zbHF2UecN91.Kwk45CnenXmfo9y297XJHvata6H.UiK', 100000, 'mzx@void.com', 'mzx', 1), ('8b619c88-57bc-4307-badc-a076d668b9fe', '2024-11-07 14:27:18', '2024-11-07 14:27:21', '$2b$12$5fAZKeCdNbx1JJibbJkCSOCFQMB.BC5f0iy/yEHFvRnLvOabIG..u', 100001, 'hdx@void.com', 'hdx', 1);
COMMIT;

-- ----------------------------
-- Table structure for sys_user_channel
-- ----------------------------
DROP TABLE IF EXISTS "sys_user_channel";
CREATE TABLE "sys_user_channel" (
  "user_id" int4 NOT NULL,
  "channel_id" int4 NOT NULL
)
;

-- ----------------------------
-- Records of sys_user_channel
-- ----------------------------
BEGIN;
INSERT INTO "sys_user_channel" ("user_id", "channel_id") VALUES (1, 1), (2, 1);
COMMIT;

-- ----------------------------
-- Table structure for sys_user_guild
-- ----------------------------
DROP TABLE IF EXISTS "sys_user_guild";
CREATE TABLE "sys_user_guild" (
  "user_id" uuid NOT NULL,
  "guild_id" uuid NOT NULL,
  "nick" varchar(255) COLLATE "pg_catalog"."default",
  "avatar" varchar(255) COLLATE "pg_catalog"."default",
  "joined_at" timestamp(6)
)
;

-- ----------------------------
-- Records of sys_user_guild
-- ----------------------------
BEGIN;
INSERT INTO "sys_user_guild" ("user_id", "guild_id", "nick", "avatar", "joined_at") VALUES ('73ac52cb-9538-43e8-ad36-ad251fc415a4', 'fe05e724-54f5-422d-8dd8-e6d1b4de542e', 'mzx111', NULL, '2024-11-07 17:30:03'), ('8b619c88-57bc-4307-badc-a076d668b9fe', 'fe05e724-54f5-422d-8dd8-e6d1b4de542e', 'hdx111', NULL, '2024-11-07 17:30:03');
COMMIT;

-- ----------------------------
-- Alter sequences owned by
-- ----------------------------
ALTER SEQUENCE "sys_channel_id_seq"
OWNED BY "sys_channel"."id";
SELECT setval('"sys_channel_id_seq"', 1, false);

-- ----------------------------
-- Alter sequences owned by
-- ----------------------------
ALTER SEQUENCE "sys_user_code_seq"
OWNED BY "sys_user"."code";
SELECT setval('"sys_user_code_seq"', 100001, true);

-- ----------------------------
-- Auto increment value for sys_channel
-- ----------------------------
SELECT setval('"sys_channel_id_seq"', 1, false);

-- ----------------------------
-- Primary Key structure for table sys_channel
-- ----------------------------
ALTER TABLE "sys_channel" ADD CONSTRAINT "sys_channel_pkey" PRIMARY KEY ("id");

-- ----------------------------
-- Primary Key structure for table sys_guild
-- ----------------------------
ALTER TABLE "sys_guild" ADD CONSTRAINT "sys_group0_pkey" PRIMARY KEY ("id");

-- ----------------------------
-- Auto increment value for sys_user
-- ----------------------------
SELECT setval('"sys_user_code_seq"', 100001, true);

-- ----------------------------
-- Primary Key structure for table sys_user
-- ----------------------------
ALTER TABLE "sys_user" ADD CONSTRAINT "sys_user1_pkey" PRIMARY KEY ("id");
